<?php
ob_start();
include "include/config.inc.php";
$parties = array();
$m= 0 ;
$i=0;
$msg = "";
$selectParties = "SELECT partyId, partyName, address, phone1, phone2, documentsId, otherInfo
                    FROM party";
$selectPartiesRes = mysql_query($selectParties);
while($selectPartiesRow = mysql_fetch_array($selectPartiesRes))
{
  $parties[$m]['partyId']     = $selectPartiesRow['partyId'];
  $parties[$m]['partyName']   = $selectPartiesRow['partyName'];
  $parties[$m]['address']     = $selectPartiesRow['address'];
  $parties[$m]['phone1']      = $selectPartiesRow['phone1'];
  $parties[$m]['phone2']      = $selectPartiesRow['phone2'];
  $parties[$m]['otherInfo']   = $selectPartiesRow['otherInfo'];
  $documents[$m] = array();
  
  if(strlen($selectPartiesRow['documentsId'] > 0))
  {
    $selectDocument = "SELECT document FROM documents 
                        WHERE documentsId IN (".$selectPartiesRow['documentsId'].")";
    $selectDocumentRes = mysql_query($selectDocument);
    while($selectDocumentRow = mysql_fetch_array($selectDocumentRes))
    {
    	$documents[$m][$i] = $selectDocumentRow['document'];
    	$i++;
    }
  }
  $parties[$m]['documentsId'] = implode(',',$documents[$m]);
  $m++;
}
if(isset($_REQUEST['msg']))
{
  $msg = $_REQUEST['msg'] ;
}
$smarty->assign('parties',$parties);
$smarty->assign('msg',$msg);
$smarty->display('displayClient.tpl');
?>